package com.xdq.spring.model;


import com.xdq.spring.service.CarFactory;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.List;

public class Worker implements Serializable {

    private String name;

    private String age;

    private String gender;

    private CarFactory carFactory;


    public Worker() {
        System.out.println("Worker被实例化了");
    }

    public Worker(CarFactory carFactory) {
       this.carFactory=carFactory;
    }


    public Car assemble(){
        List<Engine> engineList=carFactory.getEngineProducer().produces(1);
        List<Light> lights=carFactory.getLightProducer().produces("LED",4);
        List<Transmission> transmissions=carFactory.getTransmissionProducer().produces("auto",1);
        List<Wheel> wheels=carFactory.getWheelProducer().produces("R16/255",4);
        List<Skeleton> skeletons=carFactory.getSkeletonProducer().produces("A6L",1);
        Car car=new Car();
        car.setBrand("audi");
        car.setEngine(engineList.get(0));
        car.setLights(lights);
        car.setWheels(wheels);
        car.setTransmission(transmissions.get(0));
        car.setSkeleton(skeletons.get(0));
        return car;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public CarFactory getCarFactory() {
        return carFactory;
    }

    public void setCarFactory(CarFactory carFactory) {
        this.carFactory = carFactory;
    }
}
